#pragma once

#include <qbprotocol/include/SSFilters.h>

#include <vector>

#include "../bondlib.h"

typedef int BondID;
typedef std::vector<BondID> BondIDVec;
class S_BONDLIB_EXPORT IBrokerKeyDest {
 public:
  virtual void OnBrokerKeyFound(BondID bid, const char* brokerid,
                                void* context) {}
};

class S_BONDLIB_EXPORT
    CBondSource {  // 用于决定如何从CBondContainer中遍历获取BondID
 public:
  virtual ~CBondSource() {}
  virtual BondID GetFirstBondID() { return -1; }
  virtual BondID GetNextBondID() { return -1; }
};
////////////////////////////////////////////////////////////////////////////////
class S_BONDLIB_EXPORT CBondSourceAvailable : public CBondSource {
 protected:
  BondIDVec* m_array_result;
  BLHCONDITION m_blh;
  int m_position;
  int m_searchType;
  std::string m_searchString;

 public:
  CBondSourceAvailable(const BLHCONDITION& blh);
  virtual ~CBondSourceAvailable();
  virtual BondID GetFirstBondID() override;
  virtual BondID GetNextBondID() override;

 public:
  void SetSearch(int nType, const char* szSearch);
};

class S_BONDLIB_EXPORT CBondSourceAvailableABSBond
    : public CBondSourceAvailable {
 public:
  CBondSourceAvailableABSBond(const BLHCONDITION& blh)
      : CBondSourceAvailable(blh){};
  virtual ~CBondSourceAvailableABSBond(){};
  BondID GetFirstBondID();
};

class S_BONDLIB_EXPORT CBondSourceCFETSAvailable : public CBondSourceAvailable {
 public:
  CBondSourceCFETSAvailable(const BLHCONDITION& blh)
      : CBondSourceAvailable(blh){};
  virtual ~CBondSourceCFETSAvailable(){};
  virtual BondID GetFirstBondID() override;
};

// TODO attention

class S_BONDLIB_EXPORT CBondSourceCFETSDealAvailable
    : public CBondSourceAvailable {
 public:
  CBondSourceCFETSDealAvailable(const BLHCONDITION& blh)
      : CBondSourceAvailable(blh){};
  virtual ~CBondSourceCFETSDealAvailable(){};
  BondID GetFirstBondID();
};

class S_BONDLIB_EXPORT CBondSourceStatic : public CBondSource {
 protected:
  int m_type;
  std::string m_search;
  BondIDVec* m_array_result;
  int m_position;

 public:
  CBondSourceStatic(int type, const char* szType);
  virtual ~CBondSourceStatic();
  BondID GetFirstBondID();
  BondID GetNextBondID();
  const std::string& GetSearchKey() const { return m_search; }
};

class S_BONDLIB_EXPORT CBondSourceStaticABSBond : public CBondSourceStatic {
 public:
  CBondSourceStaticABSBond(int type, const char* szType);
  virtual ~CBondSourceStaticABSBond() {}
  BondID GetFirstBondID();
};

class S_BONDLIB_EXPORT CBondCFETSSourceStatic : public CBondSourceStatic {
 public:
  CBondCFETSSourceStatic(int type, const char* szType);
  virtual ~CBondCFETSSourceStatic() {}
  BondID GetFirstBondID();
};

// TODO CBondSourceAttention CBondSourceAttentionSort

class S_BONDLIB_EXPORT CBondSSEFISourceStatic : public CBondSourceStatic {
 public:
  CBondSSEFISourceStatic(int type, const char* szType);
  virtual ~CBondSSEFISourceStatic(){};
  BondID GetFirstBondID();
};

class S_BONDLIB_EXPORT CBondSourceSSEFIAvailable : public CBondSourceAvailable {
 public:
  CBondSourceSSEFIAvailable(const BLHCONDITION& blh)
      : CBondSourceAvailable(blh){};
  virtual ~CBondSourceSSEFIAvailable(){};
  BondID GetFirstBondID();
};